//
//  XZHMovieScaleView.m
//  Piece
//
//  Created by dllo on 16/6/14.
//  Copyright © 2016年 Northeast Dianli University. All rights reserved.
//

#import "XZHMovieScaleView.h"
#import "Masonry.h"

@interface XZHMovieScaleView ()

@end

@implementation XZHMovieScaleView {
    UILabel *scaleLabel;
}


- (instancetype)init
{
    self = [super init];
    if (self) {
        UILabel *movieScaleLabel = [[UILabel alloc] init];
        movieScaleLabel.text = @"分数比例";
        movieScaleLabel.font = [UIFont systemFontOfSize:12];
        movieScaleLabel.textColor = [UIColor colorWithRed:0.62 green:0.62 blue:0.62 alpha:1.00];
        [self addSubview:movieScaleLabel];
        [movieScaleLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.top.equalTo(self).offset(0);
            make.width.equalTo(100);
            make.height.equalTo(30);
        }];
        
        
    }
    return self;
    
}

- (void)setModel:(XZHMovieDetailModel *)model {
    if (_model != model) {
        _model = model;
        
        
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12], NSFontAttributeName,nil];
        //得到新的frame
        CGRect newRect = [model.review boundingRectWithSize:CGSizeMake(310, 8000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
        scaleLabel = [[UILabel alloc] init];
        scaleLabel.textColor = [UIColor colorWithRed:0.52 green:0.52 blue:0.52 alpha:1.00];
        scaleLabel.numberOfLines = 0;
        scaleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:scaleLabel];
        [scaleLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(8);
            make.top.equalTo(self).offset(35);
            make.width.equalTo(ScreenWidth - 16);
            make.height.equalTo(newRect.size.height);
        }];
        scaleLabel.text = model.review;
        self.ScaleBlock(newRect.size.height + 40);
    }
}


@end
